package com.example.config;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;


import java.time.LocalDateTime;


@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println("---------------执行MyMetaObjectHandler------------------");
        this.setFieldValByName("ct", LocalDateTime.now(),metaObject);
        this.setFieldValByName("mt",LocalDateTime.now(),metaObject);
        this.setFieldValByName("version",1,metaObject);
        this.setFieldValByName("deleted",0, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("mt",LocalDateTime.now(),metaObject);
    }
}
